package com.ocom.common.utils;

import org.apache.commons.lang3.StringUtils;

import java.math.BigDecimal;
import java.text.DecimalFormat;

public class F2YAndY2FUtils {

    public static String Y2F(String amount){
        amount = new BigDecimal(StringUtils.trim(amount)).multiply(new BigDecimal(100)).toString();
        double num = Double.parseDouble(amount);
        DecimalFormat df = new DecimalFormat("#.##");
        return df.format(num);
    }

    public static String F2Y(String amount){
        return new BigDecimal(amount).divide(new BigDecimal(100)).setScale(2, BigDecimal.ROUND_HALF_UP).toString();
    }

    public static void main(String[] args) {
        System.out.println(Long.valueOf(Y2F("1.01")));
        System.out.println(F2Y("6586"));
    }
}
